package Z06XianCheng.XC06JiaoHu;

import Z06XianCheng.XC01StartXianCheng.Hero;

public class HeroTest2 {

        public String name;
        public float hp;
        public int damage;

        public void AttackHero(Hero h){

            h.hp -= damage;
            System.out.printf("%s 正在攻击 %s, %s的血变成了" +
                    " %.0f%n", name, h.name, h.name, h.hp);

            if (h.isDead())
                System.out.println(h.name + "没了！");
        }

        public boolean isDead() {
            return 0 >= hp ? true:false;
        }

        public void recover(){
            hp += 1;
        }

        public void hurt(){
            if(hp == 1){
                try {
                    this.wait();
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }

            hp = hp - 1;
            System.out.printf("%s 减血1点,减少血后，" +
                    "%s的血量是%.0f%n", name, name, hp);
        }
    }

